
********Do File for Retirement Challenges Amidst Demographic Changes JPP******

use "C:\Users\zengy\Downloads\US revised retirement data 7.16.dta" 
keep country year ccode assassinations strikes guerilla_war crises purges riots revolutions anti_gov_demonst wci gdppc_ppp_2017 gdppc2015 pop pop15_64 pop65 pop15_64_percent pop65_percent lpr_55_64 lpr_65 lpr_15_plus_f lpr_15_plus_m lpr_15_plus_tot c2 aera_f aera_m aera dep old_dep young_dep dep_roc old_dep_roc young_dep_roc gdppc2015_roc pop_roc pop65_percent_roc lpr_55_64_roc lpr_65_roc aera_roc log_gdppc log_pop s_dep s_dep_roc s_pop65_percent s_log_pop s_aera s_lpr_55_64 s_log_gdppc s_gdppc2015_roc sample_flag wci_new_ lnwci_new s_lnwci_newsample used_model1 used_model2 in_model1_only in_model2_only 

***Variables***
**Codebook for Key variables
pop15-64 --- population age between 15-64 
lpr_55_64 --- labor force participantion rate for age 55-64
lpr_65 --- labor force participantion rate age above 65
lpr_15 --- labor force participantion rate for youth (m for male; f for female)
dep --- dependency ratio (old_dep for older dependency; young_dep for youth dependency)
dep_roc --- dependency ratio rate of change
wci --- weighted conflict index
wci_new_ --- adjusted confic index (calculation is shown below)
Lnwci_new --- log (t+1) wci_new
log gdppc --- log GDP per capita
gdppc2015_roc --- GDP per capita in 2015 rate of change
pop---population 
log_pop --- log population
aera--average retirement age (m for male;f for female)
aera_roc --- average retirenment age rate of change
s-vars --- standardized variables

**set dataset
encode country, gen(c2)
xtset c2 year
gen aera = (aera_f + aera_m)/2

**Recalculate wci indicator
gen wci_new = 25*assassinations + 20*strikes + 100*guerilla_war + 20*crises + 20*purges + 25*riots + 150*revolutions + 10*anti_gov_demonst
gen wci_new_ = (wci_new*100)/8
corr wci_new_ wci
sum wci_new_ wci
egen s_lg_wci_new = std(lgwci_new)

tab wci_new_
gen lnwci_new = log( wci_new+1)
sum lnwci_new lgwci_new

drop sample
gen sample = e(sample)
tab sample

***Use OLS to do the early assessment and identify the sample size
reg s_lg_wci_new s_aera i.c2 if pop65_percent >= 11&sample==1, vce(robust)
gen used_model1 = e(sample)
reg s_lg_wci_new s_lpr_55_64 i.c2 if pop65_percent >= 11&sample==1, vce(robust)
gen used_model2 = e(sample)

***Summary statistics & Correlation (Appendix)***
tabstat lnwci_new aera lpr_55_64 pop65_percent dep dep_roc log_pop gdppc2015_roc if pop65_percent >= 11 & used_model2 == 1, ///
    stat(n mean sd min max) col(stat) format(%9.3f)
	
pwcorr lnwci_new aera lpr_55_64 pop65_percent dep dep_roc log_pop gdppc2015_roc if used_model2 == 1 & pop65_percent >= 11, sig star(0.1)
  
**Table 2
xtreg s_lnwci_new s_aera if pop65_percent >= 11&used_model2==1, fe vce(robust)
	outreg2 using final2.doc, replace ctitle(Base 1)
xtreg s_lnwci_new s_lpr_55_64 if pop65_percent >= 11&used_model2==1, fe vce(robust)
	outreg2 using final2.doc, append ctitle(Base 2)
xtreg s_lnwci_new s_aera L.s_lnwci_new s_pop65_percent s_dep s_dep_roc s_log_pop 		 s_gdppc2015_roc if pop65_percent >= 11&used_model2==1, fe vce(robust)
	outreg2 using final2.doc, append ctitle(H1)
xtreg s_lnwci_new s_lpr_55_64 L.s_lnwci_new s_pop65_percent s_dep s_dep_roc s_log_pop s_gdppc2015_roc if pop65_percent >= 11&used_model2==1, fe vce(robust)
	outreg2 using final2.doc, append ctitle(H2)
	

*** Graphic***
**Fig.1
twoway ///
(line dep   year if 1970 < year < 2025 & country=="Japan", lw(thick)) ///
(line old_dep   year if 1970 < year < 2025 & country=="Japan", lw(thick) lp(dash)) ///
(line young_dep   year if 1970 < year < 2025 & country=="Japan", lw(thick) lp(dash_dot)) ///
, ///
ytitle("% of Population") ///
xtitle("Year") ///
xlabel(1980(10)2020) ///
yscale(range(0 80)) ///
ylabel(0(20)80) ///
legend(order(1 "Dependency" 2 "Elderly Dependency" 3 "Youth Dependency") ///
       rows(1) position(6) ring(0) ///
       region(lcolor(black))) /// ///
title("Japan") ///
name(g_japan, replace)
  
twoway ///
(line dep   year if 1970 < year < 2025 & country=="Spain", lw(thick)) ///
(line old_dep   year if 1970 < year < 2025 & country=="Spain", lw(thick) lp(dash)) ///
(line young_dep   year if 1970 < year < 2025 & country=="Spain", lw(thick) lp(dash_dot)) ///
, ///
ytitle("% of Population") ///
xtitle("Year") ///
xlabel(1980(10)2020) ///
yscale(range(0 80)) ///
ylabel(0(20)80) ///
legend(off) ///
title("Spain") ///
name(g_spain, replace)

graph combine g_japan g_spain, cols(2) ///
title("Dependency Ratios") ///
graphregion(margin(b+12))
	
	
***Fig.4
twoway (line aera year, lpattern(dash)) ///
	(line wci year, yaxis(2)) ///
	if country == "France", ///
   legend(position(6) ring(0) rows(1) region(lcolor(black))) ///
	graphregion(color(white)) 
	
*** Fig.5
label variable lpr_55_64 "LPR age 55-64"	
	xtline lpr_55_64 ///
    if inlist(country,"France","Japan","Sweden","United States") & year>1989, ///
    overlay ///
    yscale(range(30 85)) ylabel(30(10)80) ///
    graphregion(color(white)) ///
    xlabel(1990(5)2020) ///
    legend(position(6) ring(0) rows(2) region(lcolor(black))) ///
    title("Labor Force Participation Age 55-64") ///
    saving(old, replace)
	
label variable lpr_15_plus_tot "LPR age 15+"
	xtline lpr_15_plus_tot ///
    if inlist(country,"France","Japan","Sweden","United States") & year>1989, ///
    overlay ///
    yscale(range(30 85)) ylabel(30(10)80) ///
    graphregion(color(white)) ///
    xlabel(1990(5)2020) ///
    legend(off) ///
    title("Labor Force Participation Age 15+") ///
    saving(tot, replace)
	
graph combine old.gph tot.gph, cols(2) ///
    graphregion(color(white) margin(b+18)) ///
    xsize(8)

***Fig.6
twoway (line lpr_15_plus_m year, lpattern(dash)) ///
	(line lpr_15_plus_f year) ///
	if country == "Japan", ///
	graphregion(color(white)) title(Japan) ///
	legend(position(6) ring(0) rows(2) region(lcolor(black))) ///
	ytitle(Labor Force Participation Rate) saving(jp)
	
twoway (line lpr_15_plus_m year, lpattern(dash)) ///
	(line lpr_15_plus_f year) ///
	if country == "Sweden", ///
	graphregion(color(white)) title(Sweden) ///
	legend(position(6) ring(0) rows(2) region(lcolor(black))) ///
	ytitle(Labor Force Participation Rate) saving(sw)
	
graph combine jp.gph sw.gph, cols(2)


***Please feel free to reach out to yzeng@lasierra.edu if there is any questions!***
	